$(function () {
    let ws;
    if("WebSocket" in window) {
        // 获取招聘者id
        let clientID = $("#eid").val();
        // 创建WebSocket对象,需要注意请求路径
        ws = new WebSocket("ws://127.0.0.1:8081/hire/web/" + clientID);
        // 接收到服务端消息时触发
        ws.onmessage = function (evt) {
            let received_msg = evt.data;
            layer.msg(received_msg,{
                offset: '50px'
            });
        };
    }
});

layui.use(["table", "form"], function () {
    let table = layui.table;
    table.render({
        elem: '#resume',
        title: '简历广场',
        url: '/hire/employer/resume/center/page',
        response: {
            statusName: 'code',
            statusCode: 200,
            msgName: 'msg',
            count: 'count',
            dataName: 'data'
        },
        height: "645px",
        toolbar: '#toolbarDemo',
        page: true,
        limit: 10,
        cols: [[
            {type: 'checkbox', fixed: 'left'},
            {title: '序号', templet: '#xuhao', width: 70, align: 'center'},
            {field: 'id', title: '简历id', hide: true},
            {field: 'name', title: '姓名', width: 80},
            {field: 'sex', title: '性别', width: 60},
            {field: 'resIdentity', title: '身份', width: 80},
            {field: 'resState', title: '状态', width: 60},
            {field: 'expectIndustry', title: '期望行业', width: 100},
            {field: 'expectJob', title: '期望工作'},
            {field: 'expectCity', title: '期望城市'},
            {field: 'salaryRequirement', title: '薪资要求'},
            {field: 'phone', title: '联系电话', width: 120},
            {field: 'email', title: '邮箱', width: 200},
            {field: 'relationName', toolbar: '#barDemo', title: '操作'}
        ]],
        text: {none: '很抱歉,暂时未查询到数据,请稍后重试'}
    });
    table.on('tool(resume)', function (obj) {
        console.log(obj.event);
        if (obj.event == 'view') {
            let resumeId = obj.data.id;
            $.post('/hire/employer/resume/view', {resumeId: resumeId}, function (res) {
                if (res.code == '200') {
                    window.open('/hire/resume/resume_preview?resumeId=' + resumeId);
                } else {
                    layer.msg("很抱歉,请重试");
                }
            });
        }
    });
});